using GeneticAlgorithms.ComponentModel;
using GeneticAlgorithms.Genomes;
using GeneticAlgorithms.Operators.Fitness;

namespace GADemo.FitnessProviders
{
    [FriendlyName("'Hello World' example")]
    internal class HelloWorldFitnessProvider : IFitnessProvider<IGenome<char>, char>
    {
        const string match = "HELLOWORLD";
        #region IFitnessProvider<string> Members

        public double CalculateFitness(IGenome<char> genome)
        {
            double fitness = 0;
            for (int i = 0; (i < genome.Length) && (i < match.Length); ++i)
            {
                if (genome[i] == match[i])
                    fitness += 10;
            }

            return fitness;
        }

        #endregion
    }
}
